package com.blood.core.util.bean;

import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author yelong
 * @date 2020/9/19 16:20
 * @description
 * @Copyright
 */
public class ListUtils {

    public static <S, T> List<T> copyProperties(List<S> sources, Class<T> targetClass) {
        if (CollectionUtils.isEmpty(sources)) {
            return Collections.emptyList();
        }

        return sources.stream()
                .map(s -> BeanUtils.copyProperties(s, targetClass))
                .collect(Collectors.toList());
    }

}